<template>
  <div id='huifu'>
    <com-head :opacity='0'>回复信息</com-head>
    <div class="beizhu"><textarea style="resize:none" border maxlength=200  placeholder="请输入回复内容" v-model="content" cols="80" rows="5"></textarea>
    <span class="number">{{number}}/200</span></div>
    <com-button class="btn" :click="submit">确定</com-button>

  </div>
</template>

<script>
export default {
  name: "huifu",
  data() {
    return {
      number: "0",
      content: ""
    };
  },
  watch: {
    content: function(a, b) {
      this.number = a.length;
      console.log(this.number);
      if (this.number > 199) {
        this.$bus.$emit("toast", "字数不能超过200");
      }
    }
  },
  computed: {},

  created() {
    console.log(this.$route.query.id);
  },

  mounted() {},

  methods: {
    submit (){
      if (!this.content) {
        this.$bus.$emit("toast", '内容不能为空'); 
      } else {
        this.axios.post("apiindex/huifu", {
          token: this.token(),
          huifu: this.content,
          message_id: this.$route.query.id
        })
        .then(({ data }) => {
          
          if (data.code === "200") {
            rhis.$router.push('feedbackLog');
            this.$bus.$emit("toast", data.data);
          } else if (data.code === "204") {
            this.$bus.$emit("toast", data.data);
          }
        })
        .catch(function(error) {
          console.log(error);
        });
      }  
    },

  }
};
</script>
<style lang='scss' scoped>
#huifu {
  padding: 110px 32px;
  color: #222;
  font-size: 26px;
  line-height: 50px;
  .title {
    margin-top: 30px;
    input {
      width: 686px;
      height: 80px;
      padding-left: 20px;
      box-sizing: border-box;
      background: #f6f6f6;
      border-radius: 4px;
      border: 1Px solid #ddd;
    }
  }
  .beizhu {
    position: relative;
    textarea {
      width: 686px;
      height: 380px;
      margin-top: 20px;
      padding: 20px;
      border: 1Px solid #ddd;
      box-sizing: border-box;
      background-color: #f6f6f6;
    }
    .number {
      color: #ddd;
      position: absolute;
      bottom: 8px;
      right: 8px;
    }
  }
  .btn {
    margin-top: 400px;
    width: 686px;
  }
}
</style>